<?php
define('COUNT', 0x10);
define('SUM', 0x11);
define('AVG', 0x12);
define('MAX', 0x13);
define('MIN', 0x14);

define('RESULT', 0x20);

define('OFFSET', 0x30);
define('SIZE', 0x31);

define('ORDER', 0x40);

class XProjection{
	protected $type = null; 
	protected $value = null; 
	protected $alias = null;
	protected $parentCriteria = null;

	public function __construct($type, $value = null, $alias = null){
		$this->type = $type;
		$this->value = $value;
		$this->alias = $alias;
	}
	
	/**
	 * @return mixed
	 */
	public function type() {
		return $this->type;
	}

	/**
	 * @return mixed
	 */
	public function value() {
		return $this->value;
	}

	/**
	 * @return mixed
	 */
	public function alias() {
		return $this->alias;
	}	
		
	/**
	 * @return XCriteria
	 */
	public function parentCriteria() {
		return $this->parentCriteria;
	}
		
	/**
	 * @param XCriteria $parentCriteria
	 * @return XProjection
	 */
	public function setParentCriteria(XCriteria $parentCriteria) {
		$this->parentCriteria = $parentCriteria;
		return $this;
	}
	
	/**
	 * @return XProjection
	 */
	public static function count($value = null){
		return new self(COUNT, $value);
	}
	
	/**
	 * @return XProjection
	 */
	public static function sum($value){
		return new self(SUM, $value);
	}
	
	/**
	 * @return XProjection
	 */
	public static function avg($value){
		return new self(AVG, $value);
	}
	
	/**
	 * @return XProjection
	 */
	public static function max($value){
		return new self(MAX, $value);
	}

	/**
	 * @return XProjection
	 */
	public static function min($value){
		return new self(MIN, $value);
	}
	
	/**
	 * @return XProjection
	 */
	public static function result($value){
		return new self(RESULT, $value);
	}	
	
	/**
	 * @return XProjection
	 */
	public static function offset($value){
		return new self(OFFSET, $value);
	}	
	
	/**
	 * @return XProjection
	 */
	public static function order($value, $asc = true){
		return new self(ORDER, $value, $asc);
	}
	
	/**
	 * @return XProjection
	 */
	public static function size($value){
		return new self(SIZE, $value);
	}
	
}
?>